using System;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using Code5Systems.FormMaster.Business;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Users;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Services.Localization;

namespace Code5Systems.FormMaster
{
	
	public partial class FormMasterOptions : DotNetNuke.Entities.Modules.PortalModuleBase
	{
		
#region  Web Form Designer Generated Code
		
		//This call is required by the Web Form Designer.
		[System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
		{
			
		}
		
		protected System.Web.UI.WebControls.LinkButton cmdUpdateOptions;
		protected System.Web.UI.WebControls.CheckBox chkUseCustomXslt;
		protected System.Web.UI.WebControls.TextBox txtTableWidth;
		protected System.Web.UI.WebControls.CheckBox chkSendHTMLEmail;
		protected System.Web.UI.HtmlControls.HtmlInputFile fileXslt;
		protected System.Web.UI.WebControls.RegularExpressionValidator revXslt;
		protected System.Web.UI.WebControls.Label lblFormOptions;
		protected DotNetNuke.UI.UserControls.LabelControl lblTableWidth;
		protected System.Web.UI.WebControls.Label lblCustomXslt;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.DropDownList lstTemplateType;
		protected System.Web.UI.WebControls.CheckBox chkAuthDownloads;
		protected System.Web.UI.WebControls.CheckBox chkHidePostedBy;
		protected System.Web.UI.WebControls.CheckBox chkAllowAnonUpload;
		protected System.Web.UI.WebControls.DropDownList lstTextTemplate;
		protected DotNetNuke.UI.UserControls.LabelControl plURL;
		protected DotNetNuke.UI.UserControls.UrlControl ctlRedirectURL;
		protected System.Web.UI.WebControls.TextBox txtTableClass;
		protected System.Web.UI.WebControls.CheckBox chkInSurveyMode;
		protected System.Web.UI.WebControls.DropDownList lstTableAlignment;
		protected DropDownList lstFormTableAllignment;
		protected System.Web.UI.WebControls.CheckBox chkSendAutoResponse;
		protected System.Web.UI.WebControls.CheckBox chkSendAutoResponder;
		protected System.Web.UI.WebControls.DropDownList lstAutoRespToField;
		protected System.Web.UI.WebControls.TextBox txtAutoRespSubject;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfvAutoRespSubject;
		protected System.Web.UI.WebControls.CheckBox chkUseFieldForSubject;
		protected System.Web.UI.WebControls.DropDownList lstSubjectFieldValue;
		protected System.Web.UI.WebControls.DropDownList lstSubjectFieldValue2;
		protected System.Web.UI.WebControls.TextBox txtAutoRespFromEmail;
		protected System.Web.UI.WebControls.RegularExpressionValidator revAutoRespFromEmail;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfvAutoRespFromEmail;
		protected System.Web.UI.WebControls.TextBox txtSilentPostUrl;
		protected DotNetNuke.UI.UserControls.UrlControl ctlARAttachment;
		protected System.Web.UI.WebControls.TextBox txtRequiredFieldSymbol;
		protected DotNetNuke.UI.UserControls.SectionHeadControl dshValidationSummaryOptions;
		protected CheckBox chkEnableClientScript;
		protected CheckBox chkUseValidationSummary;
		protected TextBox txtValidationSummaryHeading;
		protected TextBox txtValidationSummaryCssClass;
		protected CheckBox chkShowValidationSummaryMessageBox;
		protected CheckBox chkShowValidationSummary;
		protected DropDownList lstValidationSummaryMode;
		protected DropDownList lstValidationSummaryInsertAtRow;
		protected DropDownList lstValidationSummaryHorzAlign;
		protected CheckBox chkSupressFieldValidationMessages;
		protected TextBox txtSuppressedFieldCharacter;
		protected TextBox txtFormTableWidth;
		protected TextBox txtFormTableHeight;
		protected CheckBox chkSendMultipart;
		protected DotNetNuke.UI.UserControls.UrlControl ctlWizardStartNextImage;
		protected DotNetNuke.UI.UserControls.UrlControl ctlWizardNextImage;
		protected DotNetNuke.UI.UserControls.UrlControl ctlWizardPrevImage;
		protected DotNetNuke.UI.UserControls.UrlControl ctlWizardFinishNextImage;
		
		//NOTE: The following placeholder declaration is required by the Web Form Designer.
		//Do not delete or move it.
		private System.Object designerPlaceholderDeclaration;
		
		private void Page_Init(System.Object sender, System.EventArgs e)
		{
			//CODEGEN: This method call is required by the Web Form Designer
			//Do not modify it using the code editor.
			InitializeComponent();
		}
		
#endregion
		
#region Private Members
		
		private DotNetNuke.Entities.Modules.PortalModuleBase _loaderCtl;
		private string strOperationSuccess;
		private FormController _objFormCtl = null;
		private FormInfo _objFormInfo;
		private ModuleInfo modInfo = null;

		#endregion

		#region Event Handlers

		private void Page_Load(System.Object sender, System.EventArgs e)
		{
			try
			{
				this.LoaderCtl = (PortalModuleBase) this.Parent.Parent;

				ModuleController modCtl = new ModuleController();
				modInfo = modCtl.GetModule(this.LoaderCtl.ModuleId);

				strOperationSuccess = Localization.GetString("OperationSuccess", this.LocalResourceFile);
				
				_objFormCtl = new Code5Systems.FormMaster.Business.FormController(ModuleId);
				_objFormInfo = _objFormCtl.FormInfo;

				if (!Page.IsPostBack)
				{
					BindData();
				}
				
			}
			catch (Exception exc)
			{
				Exceptions.ProcessModuleLoadException(this, exc);
			}
		}
		
		private void BindData()
		{
			FormSettings objFormSettings = Utility.GetFormSettings(ModuleId);
			
			// Form Master Form Options Page

			this.txtFormName.Text = _objFormCtl.FormInfo.FormName;
			this.txtOuterTableClass.Text = _objFormCtl.FormInfo.TableClass;
			this.lstEmailSendAction.SelectedIndex = this.lstEmailSendAction.Items.IndexOf(this.lstEmailSendAction.Items.FindByValue(_objFormInfo.EmailSendAction.ToString()));
			this.lstEmailFromAction.SelectedIndex = this.lstEmailFromAction.Items.IndexOf(this.lstEmailFromAction.Items.FindByValue(_objFormInfo.EmailFromAction.ToString()));
			this.lstReplyToAction.SelectedIndex = this.lstReplyToAction.Items.IndexOf(this.lstReplyToAction.Items.FindByValue((_objFormInfo.ReplyToAction).ToString()));
			this.txtEmailSendTo.Text = _objFormInfo.EmailSendTo;
			this.txtReplyTo.Text = _objFormInfo.ReplyTo;
			this.chkSaveData.Checked = _objFormInfo.SaveData;

			this.chkUseCaptcha.Checked = _objFormInfo.UseCaptcha;
			this.txtCaptchaCharacters.Text = _objFormInfo.CaptchaCharacters;

			if (String.IsNullOrWhiteSpace(_objFormInfo.FromAddress))
			{
				this.txtFrom.Text = this.PortalSettings.Email;
			}
			else
			{
				this.txtFrom.Text = _objFormInfo.FromAddress;
			}

			this.txtBCC.Text = _objFormInfo.BccAddress;

			this.chkShowCCMe.Checked = _objFormInfo.ShowCcMe;
			_objFormCtl.BindDynamicControls(this.lstCCMeEmail, ModuleId);
			this.lstCCMeEmail.Enabled = _objFormInfo.ShowCcMe;
			this.lstCCMeEmail.SelectedIndex = this.lstCCMeEmail.Items.IndexOf(this.lstCCMeEmail.Items.FindByValue(_objFormInfo.EmailCcMeControl));

			_objFormCtl.BindDynamicControls(this.lstEmailSendToControl, ModuleId);

			_objFormCtl.BindDynamicControls(this.lstEmailSendFromControl, ModuleId);

			_objFormCtl.BindDynamicControls(this.lstEmailReplyToControl, ModuleId);

			SetSendToControls();

			SetSendFromControls();

			SetReplyToControls();

			// End Form Master Form Options Page

			//Take care of Data Binding Here
			this.lstCaptchaTypeList.SelectedIndex = this.lstCaptchaTypeList.Items.IndexOf(this.lstCaptchaTypeList.Items.FindByValue(
				objFormSettings.CaptchaType.EnumToInt<CaptchaType>().ToString()));
			this.txtSiteKey.Text = objFormSettings.SiteKey;
			this.txtSecretKey.Text = objFormSettings.SecretKey;

			SetSendAddCaptchaToControls();

			this.txtTableWidth.Text = objFormSettings.TableWidth;
			this.txtTableClass.Text = objFormSettings.TableClass;
			this.txtFormTableWidth.Text = objFormSettings.FormTableWidth;
			this.txtFormTableHeight.Text = objFormSettings.FormTableHeight;
			this.chkInSurveyMode.Checked = objFormSettings.InSurveyMode;
			this.chkUseCustomXslt.Checked = objFormSettings.UseCustomXslt;
			if (this.chkUseCustomXslt.Checked)
			{
				Utility.DisableAjax(cmdUpdateOptions);
			}
			this.chkSendHTMLEmail.Checked = objFormSettings.SendHtmlEmail;
			this.chkSendMultipart.Checked = objFormSettings.SendMultipart;
			this.chkExcludeFieldsHiddenByFieldRulesInEmails.Checked = objFormSettings.ExcludeFieldsHiddenByFieldRulesInEmails;
			this.chkAllowAnonUpload.Checked = objFormSettings.AllowAnonUploads;
			this.chkAuthDownloads.Checked = objFormSettings.AuthFileDownloads;
			this.chkHidePostedBy.Checked = objFormSettings.HidePostedBy;
			this.chkSendAutoResponder.Checked = objFormSettings.SendAutoResponder;
			this.rfvAutoRespFromEmail.Enabled = this.chkUseValidationSummary.Checked;
			this.rfvAutoRespSubject.Enabled = this.chkSendAutoResponder.Checked;
			this.lstAutoRespToField.Enabled = objFormSettings.SendAutoResponder;
			this.txtAutoRespFromEmail.Text = objFormSettings.AutoRespFromEmail;
			this.rfvAutoRespSubject.Enabled = objFormSettings.SendAutoResponder;
			this.txtAutoRespSubject.Text = objFormSettings.AutoRespSubject;

			this.lstTableAlignment.SelectedIndex = this.lstTableAlignment.Items.IndexOf(this.lstTableAlignment.Items.FindByValue(
				objFormSettings.TableAlignment.EnumToInt<HorizontalAlign>().ToString().ToString()));

			this.lstFormTableAllignment.SelectedIndex = this.lstFormTableAllignment.Items.IndexOf(this.lstFormTableAllignment.Items.FindByValue(
				objFormSettings.FormTableAlignment.EnumToInt<HorizontalAlign>().ToString()));

			this.chkUseFieldForSubject.Checked = objFormSettings.UseFieldForSubject;
			this.chkAppendToSubject.Checked = objFormSettings.AppendToSubject;
			this.chkDataDirectLink.Checked = objFormSettings.DataDirectLink;
			this.lstSubjectFieldValue.Enabled = objFormSettings.UseFieldForSubject;
			this.lstSubjectFieldValue2.Enabled = objFormSettings.UseFieldForSubject;
			this.chkAppendToSubject.Enabled = objFormSettings.UseFieldForSubject;
			
			_objFormCtl.BindDynamicControls(this.lstAutoRespToField, ModuleId);
			this.lstAutoRespToField.SelectedIndex = this.lstAutoRespToField.Items.IndexOf(this.lstAutoRespToField.Items.FindByValue(objFormSettings.AutoRespToField));
			
			_objFormCtl.BindDynamicControls(this.lstSubjectFieldValue, ModuleId);
			this.lstSubjectFieldValue.SelectedIndex = this.lstSubjectFieldValue.Items.IndexOf(this.lstSubjectFieldValue.Items.FindByValue(objFormSettings.SubjectFieldValue));
			
			_objFormCtl.BindDynamicControls(this.lstSubjectFieldValue2, ModuleId);
			this.lstSubjectFieldValue2.Items.Insert(0, new ListItem(Localization.GetString("NotSpecified.Text", LocalResourceFile), "0"));
			this.lstSubjectFieldValue2.SelectedIndex = this.lstSubjectFieldValue2.Items.IndexOf(this.lstSubjectFieldValue2.Items.FindByValue(objFormSettings.SubjectFieldValue2));
			
			this.txtSilentPostUrl.Text = objFormSettings.SilentPostUrl;
			this.chkSuppressReqFldText.Checked = objFormSettings.SuppressReqFldText;
			this.txtRequiredFieldSymbol.Text = objFormSettings.RequiredFieldSymbol;
			
			this.lstTemplateType.SelectedIndex = this.lstTemplateType.Items.IndexOf(this.lstTemplateType.Items.FindByValue(
				objFormSettings.TemplateType.EnumToInt<TemplateType>().ToString()));

			this.lstEncoding.SelectedIndex = this.lstEncoding.Items.IndexOf(this.lstEncoding.Items.FindByValue(
				objFormSettings.Encoding.EnumToInt<EmailEncoding>().ToString()));
			
			FileController oFileCtl = new FileController();
			DotNetNuke.Services.FileSystem.FileInfo oFileInfo = default(DotNetNuke.Services.FileSystem.FileInfo);
			
			this.ctlARAttachment.UrlType = "N";
			if (objFormSettings.ARAttachment != string.Empty)
			{
				this.ctlARAttachment.UrlType = "F";
				oFileInfo = oFileCtl.GetFileById(int.Parse(objFormSettings.ARAttachment), PortalId);
				if (oFileInfo != null)
				{
					this.ctlARAttachment.Url = oFileInfo.Folder + oFileInfo.FileName;
				}
			}
			
			this.ctlRedirectURL.UrlType = objFormSettings.RedirectType;
			if (objFormSettings.RedirectType == "F")
			{
				oFileInfo = oFileCtl.GetFileById(int.Parse(objFormSettings.RedirectUrl), PortalId);
				if (oFileInfo != null)
				{
					this.ctlRedirectURL.Url = oFileInfo.Folder + oFileInfo.FileName;
				}
			}
			else
			{
				this.ctlRedirectURL.Url = objFormSettings.RedirectUrl;
			}
			
			string strTemplateDir = Server.MapPath(this.ControlPath + "Templates/" + PortalId + "/");
			
			if (!Directory.Exists(strTemplateDir))
			{
				strTemplateDir = Server.MapPath(this.ControlPath + "Templates/");
			}
			
			if (Directory.Exists(strTemplateDir))
			{
				
				string[] dirs = Directory.GetDirectories(strTemplateDir);
				string dir = default(string);
				foreach (string tempLoopVar_dir in dirs)
				{
					dir = tempLoopVar_dir;
					dir = dir.Replace(strTemplateDir, "");
					this.lstTextTemplate.Items.Add(dir);
				}
				
				this.lstTextTemplate.SelectedIndex = this.lstTextTemplate.Items.IndexOf(this.lstTextTemplate.Items.FindByValue(objFormSettings.TextTemplate));
			}
			else
			{
				this.lstTextTemplate.Items.Add("Default");
			}
			
			this.chkEnableClientScript.Checked = objFormSettings.EnableClientScript;
			this.chkUseFormErrorFormatting.Checked = objFormSettings.UseFormErrorFormatting;
			this.chkUseValidationSummary.Checked = objFormSettings.UseValidationSummary;
			this.txtValidationSummaryHeading.Text = objFormSettings.ValidationSummaryHeading;
			this.txtValidationSummaryCssClass.Text = objFormSettings.ValidationSummaryCssClass;
			this.chkShowValidationSummary.Checked = objFormSettings.ShowValidationSummary;
			this.chkShowValidationSummaryMessageBox.Checked = objFormSettings.ShowValidationSummaryMessageBox;

			this.lstValidationSummaryMode.SelectedIndex = this.lstValidationSummaryMode.Items.IndexOf(
				this.lstValidationSummaryMode.Items.FindByValue(objFormSettings.ValidationSummaryMode.EnumToInt<ValidationSummaryDisplayMode>().ToString()));
			
			this.lstValidationSummaryInsertAtRow.Items.Add(new ListItem(Localization.GetString("Top", this.LocalResourceFile), int.MinValue.ToString()));
			for (int index = 1; index <= _objFormCtl.Pages[0].TableRows; index++)
			{
				this.lstValidationSummaryInsertAtRow.Items.Add(new ListItem((string)((index).ToString()), index.ToString()));
			}
			this.lstValidationSummaryInsertAtRow.Items.Add(new ListItem(Localization.GetString("Bottom", this.LocalResourceFile), int.MaxValue.ToString()));
			this.lstValidationSummaryInsertAtRow.SelectedIndex = this.lstValidationSummaryInsertAtRow.Items.IndexOf(this.lstValidationSummaryInsertAtRow.Items.FindByValue(
				objFormSettings.ValidationSummaryInsertAtRow.ToString()));
			
			if (objFormSettings.ResponsiveLayout)
			{
				this.trValSmryInsterAtRow.Visible = false;
			}

			this.lstValidationSummaryHorzAlign.SelectedIndex = this.lstValidationSummaryHorzAlign.Items.IndexOf(this.lstValidationSummaryHorzAlign.Items.FindByValue
				(objFormSettings.ValidationSummaryHorzAlign.EnumToInt<HorizontalAlign>().ToString()));

			this.chkSupressFieldValidationMessages.Checked = objFormSettings.SupressFieldValidationMessages;
			this.txtSuppressedFieldCharacter.Text = objFormSettings.SuppressedFieldCharacter;

			this.lstWizardButtonType.SelectedIndex = this.lstWizardButtonType.Items.IndexOf(this.lstWizardButtonType.Items.FindByValue(
				objFormSettings.WizardButtonType.EnumToInt<Business.ButtonType>().ToString()));

			this.txtWizardButtonClass.Text = objFormSettings.WizardButtonClass;
			
			if (objFormSettings.WizardButtonType == Code5Systems.FormMaster.Business.ButtonType.ImageButton)
			{
				this.trButtonImage.Visible = true;
				
				if (!string.IsNullOrEmpty(objFormSettings.WizardStartNextImage))
				{
					oFileInfo = oFileCtl.GetFileById(int.Parse(objFormSettings.WizardStartNextImage), PortalId);
					if (oFileInfo != null)
					{
						this.ctlWizardStartNextImage.Url = oFileInfo.Folder + oFileInfo.FileName;
						this.imgWizardStartNextImage.ImageUrl = PortalSettings.HomeDirectory + oFileInfo.Folder + oFileInfo.FileName;
						this.imgWizardStartNextImage.Visible = true;
						this.lblWizardStartNextImage.Text = Localization.GetString("CurrentStartFile.Text", this.LocalResourceFile);
						this.lblWizardStartNextImage.Text += oFileInfo.Folder + oFileInfo.FileName;
					}
				}
				
				if (!string.IsNullOrEmpty(objFormSettings.WizardNextImage))
				{
					oFileInfo = oFileCtl.GetFileById(int.Parse(objFormSettings.WizardNextImage), PortalId);
					if (oFileInfo != null)
					{
						this.ctlWizardNextImage.Url = oFileInfo.Folder + oFileInfo.FileName;
						this.imgNextButton.ImageUrl = PortalSettings.HomeDirectory + oFileInfo.Folder + oFileInfo.FileName;
						this.imgNextButton.Visible = true;
						this.lblCurrentNextFile.Text = Localization.GetString("CurrentNextFile.Text", this.LocalResourceFile);
						this.lblCurrentNextFile.Text += oFileInfo.Folder + oFileInfo.FileName;
					}
				}
				
				if (!string.IsNullOrEmpty(objFormSettings.WizardPrevImage))
				{
					oFileInfo = oFileCtl.GetFileById(int.Parse(objFormSettings.WizardPrevImage), PortalId);
					if (oFileInfo != null)
					{
						this.ctlWizardPrevImage.Url = oFileInfo.Folder + oFileInfo.FileName;
						this.imgPrevButton.ImageUrl = PortalSettings.HomeDirectory + oFileInfo.Folder + oFileInfo.FileName;
						this.imgPrevButton.Visible = true;
						this.lblCurrentPrevFile.Text = Localization.GetString("CurrentPrevFile.Text", this.LocalResourceFile);
						this.lblCurrentPrevFile.Text += oFileInfo.Folder + oFileInfo.FileName;
					}
				}
				
				if (!string.IsNullOrEmpty(objFormSettings.WizardFinishNextImage))
				{
					oFileInfo = oFileCtl.GetFileById(int.Parse(objFormSettings.WizardFinishNextImage), PortalId);
					if (oFileInfo != null)
					{
						this.ctlWizardFinishNextImage.Url = oFileInfo.Folder + oFileInfo.FileName;
						this.imgWizardFinishNextImage.ImageUrl = PortalSettings.HomeDirectory + oFileInfo.Folder + oFileInfo.FileName;
						this.imgWizardFinishNextImage.Visible = true;
						this.lblWizardFinishNextImage.Text = Localization.GetString("CurrentFinishFile.Text", this.LocalResourceFile);
						this.lblWizardFinishNextImage.Text += oFileInfo.Folder + oFileInfo.FileName;
					}
				}
			}
			else
			{
				this.trButtonImage.Visible = false;
			}
			
			this.txtWizardStartText.Text = objFormSettings.WizardStartText;
			this.txtWizardNextText.Text = objFormSettings.WizardNextText;
			this.txtWizardPrevText.Text = objFormSettings.WizardPrevText;
			this.txtWizardFinishText.Text = objFormSettings.WizardFinishText;
			this.txtWizardStepText.Text = objFormSettings.WizardStepText;
			this.txtWizardStepClass.Text = objFormSettings.WizardStepClass;

			this.lstWizardStepsAlign.SelectedIndex = this.lstWizardStepsAlign.Items.IndexOf(this.lstWizardStepsAlign.Items.FindByValue(
				objFormSettings.WizardStepsAlign.EnumToInt<HorizontalAlign>().ToString()));

			this.txtWizardLegendClass.Text = objFormSettings.WizardLegendClass;

			this.lstWizardLegendAlign.SelectedIndex = this.lstWizardLegendAlign.Items.IndexOf(this.lstWizardLegendAlign.Items.FindByValue(
				objFormSettings.WizardLegendAlign.EnumToInt<HorizontalAlign>().ToString()));

			this.txtWizardStepTitleClass.Text = objFormSettings.WizardStepTitleClass;

			this.lstWizardTitleAlign.SelectedIndex = this.lstTableAlignment.Items.IndexOf(this.lstTableAlignment.Items.FindByValue(
				objFormSettings.WizardTitleAlign.EnumToInt<HorizontalAlign>().ToString()));

			this.chkWizardShowSteps.Checked = objFormSettings.WizardShowSteps;

			this.txtGroupWidth.Text = objFormSettings.GroupWidth.ToString();
			this.txtLabelWidth.Text = objFormSettings.LabelWidth.ToString();
			this.chkResponsiveLayout.Checked = objFormSettings.ResponsiveLayout;
			this.chkHardRowBreaks.Checked = objFormSettings.HardRowBreaks;
			this.chkUseDefaultFieldFormatting.Checked = objFormSettings.UseDefaultFieldFormatting;

			this.lstLabelAlign.SelectedIndex = this.lstLabelAlign.Items.IndexOf(this.lstLabelAlign.Items.FindByValue(
				objFormSettings.LabelAlign.EnumToInt<HorizontalAlign>().ToString()));

			this.txtCellHeight.Text = objFormSettings.CellHeight.ToString();

			#region Web Service Options

			UserController objUsers = new UserController();
			UserInfo objUser = UserController.GetCurrentUserInfo();

			if (!(objUser.IsSuperUser || DotNetNuke.Security.PortalSecurity.IsInRole("Administrators")))
			{
				if (!DotNetNuke.Security.Permissions.ModulePermissionController.HasModuleAccess(DotNetNuke.Security.SecurityAccessLevel.Edit, "edit", modInfo))
					Response.Redirect("~/" + DotNetNuke.Common.Globals.glbDefaultPage);
			}

			DotNetNuke.Security.Roles.RoleController oRolesCtl = new DotNetNuke.Security.Roles.RoleController();

			this.cblAccessRoles.DataSource = oRolesCtl.GetPortalRoles(PortalId);
			this.cblAccessRoles.DataBind();

			string[] aryRoles = null;

			if (objFormSettings.WsAccessRoles != string.Empty)
			{
				aryRoles = objFormSettings.WsAccessRoles.Split(',');

				for (int i = 0; i <= aryRoles.Length - 1; i++)
				{
					if (this.cblAccessRoles.Items.FindByText(aryRoles[i]) != null)
					{
						this.cblAccessRoles.Items.FindByText(aryRoles[i]).Selected = true;
					}

				}
			}

			this.txtWsUrl.Text = Utility.GetPortalAlias(PortalId) + "DesktopModules/Code5systems_FormMaster/FormData.asmx";

			#endregion Web Service Options
		}
		
		protected void cmdUpdateOptions_Click(object sender, System.EventArgs e)
		{
			Page.Validate();
			if (Page.IsValid)
			{
				try
				{
					ModuleController objModules = new ModuleController();
					
					#region Form Options
					
					_objFormInfo.LastModifiedByID = this.UserId;
					_objFormInfo.FormName = this.txtFormName.Text;
					_objFormInfo.TableClass = this.txtOuterTableClass.Text;
					_objFormInfo.EmailSendAction = Convert.ToByte(this.lstEmailSendAction.SelectedValue);
					_objFormInfo.EmailFromAction = Convert.ToByte(this.lstEmailFromAction.SelectedValue);
					_objFormInfo.ReplyToAction = Convert.ToByte(this.lstReplyToAction.SelectedValue);

					if ((FormInfo.EmailActionNone)_objFormInfo.EmailSendAction == Code5Systems.FormMaster.Business.FormInfo.EmailActionNone.UserDefined)
					{
						string[] strAryEmails = this.txtEmailSendTo.Text.Replace(" ", "").Split(';');
						foreach (string email in strAryEmails)
						{
							if (!Utility.ValidateEmailAddressFormat(email))
							{
								throw (new ArgumentException(email + " " + Localization.GetString("InvalidEmail", this.LocalResourceFile)));
							}
						}
					}

					_objFormInfo.EmailSendTo = this.txtEmailSendTo.Text;
					_objFormInfo.EmailSendToControl = this.lstEmailSendToControl.SelectedValue;
					_objFormInfo.EmailSendFromControl = this.lstEmailSendFromControl.SelectedValue;
					_objFormInfo.ReplyTo = this.txtReplyTo.Text;
					_objFormInfo.ReplyToControl = this.lstEmailReplyToControl.SelectedValue;
					_objFormInfo.SaveData = this.chkSaveData.Checked;
					_objFormInfo.ShowCcMe = this.chkShowCCMe.Checked;
					_objFormInfo.EmailCcMeControl = this.lstCCMeEmail.SelectedValue;
					
					_objFormInfo.UseCaptcha = this.chkUseCaptcha.Checked;
					_objFormInfo.CaptchaCharacters = this.txtCaptchaCharacters.Text;
					
					_objFormInfo.FromAddress = this.txtFrom.Text;
					_objFormInfo.BccAddress = this.txtBCC.Text;
					_objFormCtl.Update(_objFormInfo);

					objModules.UpdateModuleSetting(ModuleId, "TableWidth", this.txtTableWidth.Text);
					objModules.UpdateModuleSetting(ModuleId, "TableClass", this.txtTableClass.Text);
					objModules.UpdateModuleSetting(ModuleId, "FormTableWidth", this.txtFormTableWidth.Text);
					objModules.UpdateModuleSetting(ModuleId, "FormTableHeight", this.txtFormTableHeight.Text);
					objModules.UpdateModuleSetting(ModuleId, "InSurveyMode", System.Convert.ToString(this.chkInSurveyMode.Checked));
					objModules.UpdateModuleSetting(ModuleId, "SilentPostUrl", this.txtSilentPostUrl.Text);
					objModules.UpdateModuleSetting(ModuleId, "ExcludeFieldsHiddenByFieldRulesInEmails", System.Convert.ToString(this.chkExcludeFieldsHiddenByFieldRulesInEmails.Checked));
					objModules.UpdateModuleSetting(ModuleId, "AllowAnonUploads", System.Convert.ToString(this.chkAllowAnonUpload.Checked));
					objModules.UpdateModuleSetting(ModuleId, "AuthFileDownloads", System.Convert.ToString(this.chkAuthDownloads.Checked));
					objModules.UpdateModuleSetting(ModuleId, "HidePostedBy", System.Convert.ToString(this.chkHidePostedBy.Checked));
					objModules.UpdateModuleSetting(ModuleId, "TableAlignment", this.lstTableAlignment.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "FormTableAlignment", this.lstFormTableAllignment.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "CaptchaType", this.lstCaptchaTypeList.SelectedValue);
					objModules.UpdateModuleSetting(ModuleId, "SiteKey", this.txtSiteKey.Text);
					objModules.UpdateModuleSetting(ModuleId, "SecretKey", this.txtSecretKey.Text);
					#endregion Form Options

					#region Email Options

					objModules.UpdateModuleSetting(ModuleId, "UseCustomXslt", System.Convert.ToString(this.chkUseCustomXslt.Checked));
					objModules.UpdateModuleSetting(ModuleId, "SendHtmlEmail", System.Convert.ToString(this.chkSendHTMLEmail.Checked));
					objModules.UpdateModuleSetting(ModuleId, "SendMultipart", System.Convert.ToString(this.chkSendMultipart.Checked));
					objModules.UpdateModuleSetting(ModuleId, "UseFieldForSubject", System.Convert.ToString(this.chkUseFieldForSubject.Checked));
					objModules.UpdateModuleSetting(ModuleId, "AppendToSubject", System.Convert.ToString(this.chkAppendToSubject.Checked));
					objModules.UpdateModuleSetting(ModuleId, "DataDirectLink", System.Convert.ToString(this.chkDataDirectLink.Checked));
					objModules.UpdateModuleSetting(ModuleId, "SubjectFieldValue", this.lstSubjectFieldValue.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "SubjectFieldValue2", this.lstSubjectFieldValue2.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "TemplateType", this.lstTemplateType.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "Encoding", this.lstEncoding.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "TextTemplate", this.lstTextTemplate.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "RedirectType", this.ctlRedirectURL.UrlType);
					
					string[] aryFile = null;
					if (this.ctlARAttachment.UrlType == "F")
					{
						aryFile = this.ctlARAttachment.Url.Split('=');
						if (aryFile.Length == 2)
						{
							objModules.UpdateModuleSetting(ModuleId, "ARAttachment", aryFile[1]);
						}
						else
						{
							objModules.UpdateModuleSetting(ModuleId, "ARAttachment", "");
						}
					}
					else
					{
						objModules.UpdateModuleSetting(ModuleId, "ARAttachment", "");
					}
					
					if (this.ctlRedirectURL.UrlType == "F")
					{
						aryFile = this.ctlRedirectURL.Url.Split('=');
						if (aryFile.Length == 2)
						{
							objModules.UpdateModuleSetting(ModuleId, "RedirectUrl", aryFile[1]);
						}
					}
					else
					{
						objModules.UpdateModuleSetting(ModuleId, "RedirectUrl", this.ctlRedirectURL.Url);
					}
					
					
					if (chkUseCustomXslt.Checked)
					{
						if (fileXslt.PostedFile.FileName != string.Empty)
						{
							string strFilePath = this.ControlPath + "assets/xslt/" + PortalId + "/" + ModuleId;
							string rootFolder = default(string);
							rootFolder = Server.MapPath(strFilePath);
							
							//Create the directory if it does not exist.
							if (!Directory.Exists(rootFolder))
							{
								Directory.CreateDirectory(rootFolder);
							}
							
							if (this.chkSendHTMLEmail.Checked)
							{
								this.fileXslt.PostedFile.SaveAs(rootFolder + "\\EmailSendHtml.xslt");
							}
							else
							{
								this.fileXslt.PostedFile.SaveAs(rootFolder + "\\EmailSend.xslt");
							}
							
						}
					}

					#endregion Email Options

					#region Validation Options

					objModules.UpdateModuleSetting(ModuleId, "EnableClientScript", System.Convert.ToString(this.chkEnableClientScript.Checked));
					objModules.UpdateModuleSetting(ModuleId, "UseFormErrorFormatting", System.Convert.ToString(this.chkUseFormErrorFormatting.Checked));
					objModules.UpdateModuleSetting(ModuleId, "UseValidationSummary", System.Convert.ToString(this.chkUseValidationSummary.Checked));
					objModules.UpdateModuleSetting(ModuleId, "ValidationSummaryHeading", this.txtValidationSummaryHeading.Text);
					objModules.UpdateModuleSetting(ModuleId, "ValidationSummaryCssClass", this.txtValidationSummaryCssClass.Text);
					objModules.UpdateModuleSetting(ModuleId, "ShowValidationSummary", System.Convert.ToString(this.chkShowValidationSummary.Checked));
					objModules.UpdateModuleSetting(ModuleId, "ShowValidationSummaryMessageBox", System.Convert.ToString(this.chkShowValidationSummaryMessageBox.Checked));
					objModules.UpdateModuleSetting(ModuleId, "ValidationSummaryMode", this.lstValidationSummaryMode.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "ValidationSummaryInsertAtRow", this.lstValidationSummaryInsertAtRow.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "ValidationSummaryHorzAlign", this.lstValidationSummaryHorzAlign.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "SupressFieldValidationMessages", System.Convert.ToString(this.chkSupressFieldValidationMessages.Checked));
					objModules.UpdateModuleSetting(ModuleId, "SuppressedFieldCharacter", this.txtSuppressedFieldCharacter.Text);
					objModules.UpdateModuleSetting(ModuleId, "SuppressReqFldText", System.Convert.ToString(this.chkSuppressReqFldText.Checked));
					objModules.UpdateModuleSetting(ModuleId, "RequiredFieldSymbol", this.txtRequiredFieldSymbol.Text);
					objModules.UpdateModuleSetting(ModuleId, "AutoRespToField", this.lstAutoRespToField.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "SendAutoResponder", System.Convert.ToString(this.chkSendAutoResponder.Checked));
					objModules.UpdateModuleSetting(ModuleId, "AutoRespFromEmail", this.txtAutoRespFromEmail.Text);
					objModules.UpdateModuleSetting(ModuleId, "AutoRespSubject", this.txtAutoRespSubject.Text);

					#endregion Validation Options

					#region Wizard Options

					objModules.UpdateModuleSetting(ModuleId, "WizardButtonType", (int.Parse(this.lstWizardButtonType.SelectedValue)).ToString());
					if (int.Parse(this.lstWizardButtonType.SelectedValue).ToEnum < Code5Systems.FormMaster.Business.ButtonType>() == Code5Systems.FormMaster.Business.ButtonType.ImageButton)
					{
						bool allImageButtonsDone = true;
						aryFile = this.ctlWizardStartNextImage.Url.Split('=');
						if (aryFile.Length == 2)
						{
							objModules.UpdateModuleSetting(ModuleId, "WizardStartNextImage", aryFile[1]);
						}
						else
						{
							allImageButtonsDone = false;
						}
						
						aryFile = this.ctlWizardNextImage.Url.Split('=');
						if (aryFile.Length == 2)
						{
							objModules.UpdateModuleSetting(ModuleId, "WizardNextImage", aryFile[1]);
						}
						else
						{
							allImageButtonsDone = false;
						}
						
						aryFile = this.ctlWizardPrevImage.Url.Split('=');
						if (aryFile.Length == 2)
						{
							objModules.UpdateModuleSetting(ModuleId, "WizardPrevImage", aryFile[1]);
						}
						else
						{
							allImageButtonsDone = false;
						}
						
						aryFile = this.ctlWizardFinishNextImage.Url.Split('=');
						if (aryFile.Length == 2)
						{
							objModules.UpdateModuleSetting(ModuleId, "WizardFinishNextImage", aryFile[1]);
						}
						else
						{
							allImageButtonsDone = false;
						}
						
						if (!allImageButtonsDone)
						{
							DotNetNuke.UI.Skins.Skin.AddModuleMessage(this.LoaderCtl, Localization.GetString("ImageButtonMissing", this.LocalResourceFile), DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError);
							return ;
						}
					}
					
					objModules.UpdateModuleSetting(ModuleId, "WizardStartText", this.txtWizardStartText.Text);
					objModules.UpdateModuleSetting(ModuleId, "WizardNextText", this.txtWizardNextText.Text);
					objModules.UpdateModuleSetting(ModuleId, "WizardPrevText", this.txtWizardPrevText.Text);
					objModules.UpdateModuleSetting(ModuleId, "WizardFinishText", this.txtWizardFinishText.Text);
					objModules.UpdateModuleSetting(ModuleId, "WizardStepText", this.txtWizardStepText.Text);
					objModules.UpdateModuleSetting(ModuleId, "WizardStepClass", this.txtWizardStepClass.Text);
					objModules.UpdateModuleSetting(ModuleId, "WizardStepsAlign", this.lstWizardStepsAlign.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "WizardLegendClass", this.txtWizardLegendClass.Text);
					objModules.UpdateModuleSetting(ModuleId, "WizardLegendAlign", this.lstWizardLegendAlign.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "WizardStepTitleClass", this.txtWizardStepTitleClass.Text);
					objModules.UpdateModuleSetting(ModuleId, "WizardTitleAlign", this.lstWizardTitleAlign.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "WizardShowSteps", System.Convert.ToString(this.chkWizardShowSteps.Checked));
					objModules.UpdateModuleSetting(ModuleId, "WizardButtonClass", this.txtWizardButtonClass.Text);

					objModules.UpdateModuleSetting(ModuleId, "GroupWidth", System.Convert.ToString(this.txtGroupWidth.Text));
					objModules.UpdateModuleSetting(ModuleId, "LabelWidth", System.Convert.ToString(this.txtLabelWidth.Text));
					objModules.UpdateModuleSetting(ModuleId, "ResponsiveLayout", System.Convert.ToString(this.chkResponsiveLayout.Checked));
					objModules.UpdateModuleSetting(ModuleId, "HardRowBreaks", System.Convert.ToString(this.chkHardRowBreaks.Checked));
					objModules.UpdateModuleSetting(ModuleId, "UseDefaultFieldFormatting", System.Convert.ToString(this.chkUseDefaultFieldFormatting.Checked));
					objModules.UpdateModuleSetting(ModuleId, "LabelAlign", this.lstLabelAlign.SelectedValue.ToString());
					objModules.UpdateModuleSetting(ModuleId, "CellHeight", System.Convert.ToString(this.txtCellHeight.Text));

					#endregion Wizard Options

					#region Web Service Options

					string WsAccessRoles = "";

					foreach (ListItem item in this.cblAccessRoles.Items)
					{
						if (item.Selected)
						{
							WsAccessRoles += item.Text + ",";
						}
					}

					if (WsAccessRoles.Length > 0)
					{
						WsAccessRoles = WsAccessRoles.Substring(0, WsAccessRoles.Length - 1);
					}

					objModules.UpdateModuleSetting(ModuleId, "WsAccessRoles", WsAccessRoles);

#endregion Web Service Options

					this.Cache.Remove("C5SLLC_FormSettings_" + ModuleId);
					BindData();
					
					DotNetNuke.UI.Skins.Skin.AddModuleMessage(this.LoaderCtl, strOperationSuccess, DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess);
				}
				catch (Exception exc)
				{
					Exceptions.ProcessModuleLoadException(this, exc);
				}
			}
		}

		protected void chkSendAutoResponder_CheckedChanged(System.Object sender, System.EventArgs e)
		{
			this.lstAutoRespToField.Enabled = this.chkSendAutoResponder.Checked;
			this.rfvAutoRespSubject.Enabled = this.chkSendAutoResponder.Checked;
			
			this.rfvAutoRespFromEmail.Enabled = this.chkSendAutoResponder.Checked;
			this.revAutoRespFromEmail.Enabled = this.chkSendAutoResponder.Checked;
		}

		protected void chkUseFieldForSubject_CheckedChanged(System.Object sender, System.EventArgs e)
		{
			this.lstSubjectFieldValue.Enabled = this.chkUseFieldForSubject.Checked;
			this.lstSubjectFieldValue2.Enabled = this.chkUseFieldForSubject.Checked;
			this.chkAppendToSubject.Enabled = this.chkUseFieldForSubject.Checked;
		}

		protected void chkUseCustomXslt_CheckedChanged(object sender, EventArgs e)
		{
			if (this.chkUseCustomXslt.Checked)
			{
				Utility.DisableAjax(cmdUpdateOptions);
			}
		}

		protected void lstWizardButtonType_SelectedIndexChanged(System.Object sender, System.EventArgs e)
		{
			this.trButtonImage.Visible = int.Parse(this.lstWizardButtonType.SelectedValue).ToEnum < Code5Systems.FormMaster.Business.ButtonType>() == Code5Systems.FormMaster.Business.ButtonType.ImageButton;
		}

		//DropdownList Send Action OnChange Event
		protected void lstEmailSendAction_SelectedIndexChanged(System.Object sender, System.EventArgs e)
		{
			SetSendToControls();
		}

		//DropdownList From Action OnChange Event
		protected void lstEmailFromAction_SelectedIndexChanged(System.Object sender, System.EventArgs e)
		{
			SetSendFromControls();
		}

		protected void lstReplyTo_SelectedIndexChanged(System.Object sender, System.EventArgs e)
		{
			this.SetReplyToControls();
		}

		protected void chkShowCCMe_CheckedChanged(System.Object sender, System.EventArgs e)
		{
			this.lstCCMeEmail.Enabled = this.chkShowCCMe.Checked;
		}

		protected void chkUseCaptcha_OnCheckedChanged(object sender, EventArgs e)
		{
			var isChecked = this.chkUseCaptcha.Checked;
			if (isChecked)
			{
				this.lstCaptchaTypeList.Visible = true;
				this.lstCaptchaTypeList.Enabled = true;
				this.lblCaptchaTypeList.Visible = true;
				SetSendAddCaptchaToControls();
			}
			else
			{
				HideCaptchaDetails();
			}

		}

		protected void lstCaptchaTypeList_OnSelectedIndexChanged(object sender, EventArgs e)
		{
			SetSendAddCaptchaToControls();
		}

		
		
#endregion

#region Helper Methods

		private void SetSendToControls()
		{
			switch (this.lstEmailSendAction.SelectedItem.Value)
			{
				case "1": //None
					this.txtEmailSendTo.Enabled = false;
					this.txtEmailSendTo.Visible = true;
					this.lstEmailSendToControl.Visible = false;
					this.rfvEmailSendTo.Enabled = false;
					this.lblToEmailText.Visible = true;
					this.lblToEmailList.Visible = false;
					this.txtBCC.Enabled = false;
					break;
				case "2": //Admin
					this.txtEmailSendTo.Enabled = false;
					this.txtEmailSendTo.Visible = true;
					this.txtEmailSendTo.Text = this.PortalSettings.Email;
					this.lstEmailSendToControl.Visible = false;
					this.rfvEmailSendTo.Enabled = false;
					this.lblToEmailText.Visible = true;
					this.lblToEmailList.Visible = false;
					this.txtBCC.Enabled = true;
					break;
				case "3": //User Defined
					this.txtEmailSendTo.Enabled = true;
					this.txtEmailSendTo.Visible = true;
					this.lstEmailSendToControl.Visible = false;
					this.rfvEmailSendTo.Enabled = true;
					this.lblToEmailText.Visible = true;
					this.lblToEmailList.Visible = false;
					this.txtBCC.Enabled = true;
					break;
				case "4": //Use Form Value
					this.txtEmailSendTo.Visible = false;
					this.rfvEmailSendTo.Enabled = false;
					this.lstEmailSendToControl.Visible = true;
					this.lstEmailSendToControl.Enabled = true;
					this.lblToEmailText.Visible = false;
					this.lblToEmailList.Visible = true;
					this.txtBCC.Enabled = true;
					this.lstEmailSendToControl.SelectedIndex = this.lstEmailSendToControl.Items.IndexOf(this.lstEmailSendToControl.Items.FindByValue(_objFormInfo.EmailSendToControl));
					break;
			}
		}

		private void SetSendFromControls()
		{
			switch (this.lstEmailFromAction.SelectedValue)
			{
				case "1": //Admin
					this.txtFrom.Enabled = false;
					this.txtFrom.Visible = true;
					this.txtFrom.Text = this.PortalSettings.Email;
					this.lstEmailSendFromControl.Visible = false;
					this.rfvFrom.Enabled = false;
					this.revFrom.Enabled = false;
					this.lstFromEmailText.Visible = true;
					this.lstFromEmailList.Visible = false;
					break;
				case "2": //User Defined
					this.txtFrom.Enabled = true;
					this.txtFrom.Visible = true;
					this.lstEmailSendFromControl.Visible = false;
					this.rfvFrom.Enabled = true;
					this.revFrom.Enabled = true;
					this.lstFromEmailText.Visible = true;
					this.lstFromEmailList.Visible = false;
					break;
				case "3": //Use a Control Value
					this.txtFrom.Visible = false;
					this.lstEmailSendFromControl.Visible = true;
					this.lstEmailSendFromControl.Enabled = true;
					this.rfvFrom.Enabled = false;
					this.revFrom.Enabled = false;
					this.lstFromEmailText.Visible = false;
					this.lstFromEmailList.Visible = true;
					this.lstEmailSendFromControl.SelectedIndex = this.lstEmailSendFromControl.Items.IndexOf(this.lstEmailSendFromControl.Items.FindByValue(_objFormInfo.EmailSendFromControl));
					break;
			}
		}

		private void SetReplyToControls()
		{
			switch (this.lstReplyToAction.SelectedValue)
			{
				case "1": // None
					this.txtReplyTo.Enabled = false;
					this.txtReplyTo.Visible = true;
					this.lstEmailReplyToControl.Visible = false;
					this.lblReplyToEmailText.Visible = true;
					this.lblReplyToEmailList.Visible = false;
					this.rfvReplyTo.Enabled = false;
					this.revReplyTo.Enabled = false;
					break;
				case "2": //Admin
					this.txtReplyTo.Enabled = false;
					this.txtReplyTo.Visible = true;
					this.txtReplyTo.Text = this.PortalSettings.Email;
					this.lstEmailReplyToControl.Visible = false;
					this.lblReplyToEmailText.Visible = true;
					this.lblReplyToEmailList.Visible = false;
					this.rfvReplyTo.Enabled = false;
					this.revReplyTo.Enabled = false;
					break;
				case "3": //User Defined
					this.txtReplyTo.Enabled = true;
					this.txtReplyTo.Visible = true;
					this.lstEmailReplyToControl.Visible = false;
					this.lblReplyToEmailText.Visible = true;
					this.lblReplyToEmailList.Visible = false;
					this.rfvReplyTo.Enabled = true;
					this.revReplyTo.Enabled = true;
					break;
				case "4": //Use a Control Value
					this.txtReplyTo.Visible = false;
					this.lstEmailReplyToControl.Visible = true;
					this.lstEmailReplyToControl.Enabled = true;
					this.lblReplyToEmailText.Visible = false;
					this.lblReplyToEmailList.Visible = true;
					this.rfvReplyTo.Enabled = false;
					this.revReplyTo.Enabled = false;
					this.lstEmailReplyToControl.SelectedIndex = this.lstEmailReplyToControl.Items.IndexOf(this.lstEmailReplyToControl.Items.FindByValue(_objFormInfo.ReplyToControl));
					break;
			}
		}

		private void SetSendAddCaptchaToControls()
		{
			switch (this.lstCaptchaTypeList.SelectedValue)
			{
				case "0": //DefaultCaptcha
					ChangeCaptcha();
					break;
				case "1": //GoogleReCaptcha
					ChangeCaptcha(false);
					break;
			}
		}

		private void ChangeCaptcha(bool isDefault = true)
		{
			this.txtCaptchaCharacters.Enabled = isDefault;
			this.txtCaptchaCharacters.Visible = isDefault;
			this.lblCaptchaCharaters.Visible = isDefault;

			this.txtSiteKey.Enabled = !isDefault;
			this.txtSiteKey.Visible = !isDefault;
			this.lblSiteKey.Visible = !isDefault;
			this.lblSecretKey.Visible = !isDefault;
			this.txtSecretKey.Enabled = !isDefault;
			this.txtSecretKey.Visible = !isDefault;
		}

		private void HideCaptchaDetails()
		{
			this.lstCaptchaTypeList.Enabled = false;
			this.lstCaptchaTypeList.Visible = false;
			this.lblCaptchaTypeList.Visible = false;
			this.txtCaptchaCharacters.Enabled = false;
			this.txtCaptchaCharacters.Visible = false;
			this.lblCaptchaCharaters.Visible = false;
			this.txtSiteKey.Enabled = false;
			this.txtSiteKey.Visible = false;
			this.lblSiteKey.Visible = false;
			this.lblSecretKey.Visible = false;
			this.txtSecretKey.Enabled = false;
			this.txtSecretKey.Visible = false;
		}

		#endregion
		
#region Public Properties
		public PortalModuleBase LoaderCtl
		{
			get
			{
				if (_loaderCtl == null)
				{
					_loaderCtl = this;
				}
				
				return _loaderCtl;
			}
			set
			{
				_loaderCtl = value;
			}
		}
#endregion


	}
	
}


